<cfcomponent output="false" displayName="ProjectDAO" hint="Does DAO for Projects.">

	
	<cffunction name="init" returntype="projects" access="public" output="false">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="getProjects" access="public" returntype="query" output="false" 
				hint="I get all projects from the DB.">
		<cfquery name="qryProjects" datasource="#application.dsn#">
			SELECT  *
			FROM	projects
		</cfquery>
		
		<cfreturn qryProjects>
	</cffunction>
	
	<cffunction name="saveProject" access="public" returntype="void" output="true" 
				hint="I save a new project to the DB">
		<cfargument name="name" type="string" required="yes" />
		<cfargument name="url" type="string" required="yes" />
		<cfargument name="buildfile" type="string" required="yes" />
		<cfargument name="logfile" type="string" required="yes" />
		<cfquery name="qrySaveProject" datasource="#application.dsn#">
			INSERT INTO projects (
				name, url, buildfile, logfile
			) VALUES (
				<cfqueryparam value="#arguments.name#" cfsqltype="cf_sql_varchar"/>,
				<cfqueryparam value="#arguments.url#" cfsqltype="cf_sql_varchar"/>,
				<cfqueryparam value="#arguments.buildfile#" cfsqltype="cf_sql_varchar"/>,
				<cfqueryparam value="#arguments.logfile#" cfsqltype="cf_sql_varchar"/>
			)
		</cfquery>
	</cffunction>
	
	<cffunction name="deleteProject" access="public" returntype="void" output="false" 
				hint="I delete a project from the DB.">
		<cfargument  name="projectid" type="numeric" required="true"/>
		<cfquery name="qryDeleteProject" datasource="#application.dsn#">
			DELETE FROM projects WHERE
			projectid = <cfqueryparam value="#arguments.projectid#" cfsqltype="cf_sql_integer"/>
		</cfquery>
	</cffunction>
	
</cfcomponent>